#第12章 if 语句
snum = input('请输入一个数：')
num = int(snum)
if num > 0:
    print("num is greater than Zero, it's %d" % num)
elif num == 0:
    print("num is equal to Zero")
else:
    print("num is less than Zero, it's %d" % num)
# print(num, type(num))

if not True:    # 条件表达式，大多都返回布尔型值
    print('One')

# not是非， and是与， or是或
print((2 > 1) and (3 > 2))
print(('a' > 'b') or ('c' > 'a'))

# if/else 三元表达式
A = 't' if 'spam' else 'f'
print(A)
A = 't' if '' else 'f'  # 字符串为空串，相当于False
print(A)

# 第13章 while for 循环
total = 0
i = 0
while i < 100:
    i += 1
    total += i
    # if i == 50:
    #    break
else:
    print(total, i)

# break 中止循环，执循环后边的语句
# continue  中止当前循环，执行下一次循环
# pass  占位语句，什么也不做
    if True:
        pass
    else:
        print('else')
# print('break')

L = ['a', 'b', 'c', 'd']
for (i, item) in enumerate(L, 1):
    print(i, item)

for i in range(-10, 10):
    print(i, end=' ')

print('')
for i in range(len(L)):
    print(i, L[i])
